package com.hrsaas.ext.spider.test.mybatis;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.hrsaas.ext.spider.test.mybatis.core.MybatisService;
import com.hrsaas.ext.spider.test.mybatis.core.ResumeSpiderMapper;
import com.hrsaas.ext.spider.test.mybatis.model.ResumeSpider;
import com.hrsaas.ext.spider.test.mybatis.util.SqlsessionFactoryUtil;

public class MybatisHandler implements MybatisService {

    SqlSession sqlSession = SqlsessionFactoryUtil.getSqlSessionFactory().openSession();

    ResumeSpiderMapper mapper = sqlSession.getMapper(ResumeSpiderMapper.class);

	@Override
	public int add(ResumeSpider model) {
		if (model == null){
            return 0;
        }
        int i = mapper.add(model);
        return i;
	}

	@Override
	public int delete(int id) {
		int i = mapper.delete(id);
        return i;
	}

	@Override
	public int update(ResumeSpider model) {
        if (model == null) return -1;
        int i = mapper.update(model);
        return i;
	}

	@Override
	public ResumeSpider selectById(int id) {
		return mapper.selectById(id);
	}

	@Override
	public List<ResumeSpider> selectAll() {
		return mapper.selectAll();
	}
	
}
